<?php
    /**
     * Created by JetBrains PhpStorm.
     * User: taoqili
     * Date: 12-7-18
     * Time: 上午10:42
     */
if(!$_SESSION['memberID']){
    header("Location:dlogin.html");
    exit;
}
header("Content-Type: text/html; charset=utf-8");
error_reporting(E_ERROR | E_WARNING);
include '../common/autoload.php';
//上传图片框中的描述表单名称，
$title = htmlspecialchars($_POST['pictitle'], ENT_QUOTES);
//$path = htmlspecialchars($_POST['dir'], ENT_QUOTES);
$host = 'http://'.$_SERVER['SERVER_NAME'];
$config = array(
    'simpleFolder'  => true,
    "savePath" => "/databak/images/{$_SESSION['account']}",
    "maxSize" => 1000, //单位KB
    "allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp")
);

//生成上传实例对象并完成上传
$up = new Uploader("upfile", $config);
$info = $up->getFileInfo();
//$json = '{"status":"ok", "src":"http://images.12301.cc/'.$dirname.'/'.$info['name'].'"}';

//print_r($info);
$url = "http://images.12301.cc/{$_SESSION['account']}/{$info["name"]}";

echo "{'url':'" . $url . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";

